package com.bdqn.service.impl;

import com.bdqn.service.AsyncService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * <Description> <br>
 *
 * @author tao<br>
 * @version 1.0<br>
 * @taskId: <br>
 * @createDate 2019/10/08 11:30 <br>
 * @see com.bdqn.service.impl <br>
 */
@Service
public class AsyncServiceImpl implements AsyncService {

    private static final Logger log = LoggerFactory.getLogger(AsyncServiceImpl.class);

    private static final String result = "SUCCUSS";    //返回结果

    @Override
    public String commMethod() {

        log.info("2");

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("3");

        return result;
    }

    @Override
    @Async
    public String asyncMethod() {

        log.info("2");

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("3");

        return result;
    }
}
